<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>${title}</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }

        .nav {
            margin-bottom: 20px;
        }

        .nav a {
            margin-right: 15px;
            text-decoration: none;
            color: #0066cc;
        }

        .content {
            padding: 20px;
            border: 1px solid #ddd;
            border-radius: 5px;
            max-width: 600px;
        }

        .form-group {
            margin-bottom: 15px;
        }

        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }

        input {
            width: 100%;
            padding: 8px;
            box-sizing: border-box;
            border: 1px solid #ddd;
            border-radius: 4px;
        }

        .btn {
            display: inline-block;
            padding: 8px 16px;
            background-color: #007bff;
            color: white;
            border: 1px solid #007bff;
            border-radius: 4px;
            cursor: pointer;
        }

        .btn:hover {
            background-color: #0069d9;
        }

        .actions {
            margin-top: 20px;
        }

        .actions a {
            margin-left: 10px;
            text-decoration: none;
            color: #6c757d;
        }
    </style>
</head>
<body>
<div class="nav">
    <a href="${pageContext.request.contextPath}/">首页</a>
    <a href="${pageContext.request.contextPath}/about">关于我们</a>
    <a href="${pageContext.request.contextPath}/users">用户管理</a>
</div>

<div class="content">
    <h1>${title}</h1>

    <c:choose>
        <c:when test="${user.id != null}">
            <c:url var="formAction" value="/users/${user.id}" />
        </c:when>
        <c:otherwise>
            <c:url var="formAction" value="/users" />
        </c:otherwise>
    </c:choose>

    <form action="${formAction}" method="post">
        <c:if test="${user.id != null}">
            <input type="hidden" name="id" value="${user.id}">
        </c:if>

        <div class="form-group">
            <label for="username">用户名：</label>
            <input type="text" id="username" name="username" value="${user.username}" required>
        </div>

        <div class="form-group">
            <label for="email">邮箱：</label>
            <input type="email" id="email" name="email" value="${user.email}" required>
        </div>

        <div class="actions">
            <button type="submit" class="btn">保存</button>
            <a href="${pageContext.request.contextPath}/users">取消</a>
        </div>
    </form>
</div>
</body>
</html>
